﻿using HZH_Controls.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 渐变.admin_Form
{
    public partial class admin_checkCar : Form
    {
        public admin_checkCar()
        {
            InitializeComponent();
        }

        private void admin_checkCar_Load(object sender, EventArgs e)
        {
            this.Dock = DockStyle.Fill;
        }

        private void checkdata_Load(object sender, EventArgs e)
        {
            List<DataGridViewColumnEntity> lstCulumns = new List<DataGridViewColumnEntity>();
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "RId", HeadText = "编号", Width = 70, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carname", HeadText = "车名", Width = 50, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "carid", HeadText = "车牌号", Width = 50, WidthType = SizeType.AutoSize });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "username", HeadText = "租用人", Width = 50, WidthType = SizeType.AutoSize });
            //lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "isPay", HeadText = "支付状态", Width = 50, WidthType = SizeType.AutoSize, Format = (a) => { return (bool)a ? "已支付" : "未支付"; } });
            lstCulumns.Add(new DataGridViewColumnEntity() { DataField = "returntime", HeadText = "归还时间", Width = 50, WidthType = SizeType.AutoSize, Format = (a) => { return ((DateTime)a).ToString("yyyy-MM-dd HH:mm:ss"); } });
            this.checkdata.Columns = lstCulumns;
            this.checkdata.IsShowCheckBox = true;

            string sql = "select * from backTable";
            DataTable dt = new DataTable();
            dt = DBHelper.ExecuteQuery(sql);
            this.checkdata.DataSource = dt;
            this.checkdata.First();
        }

        private void btnCheck_Click(object sender, EventArgs e)
        {
            string id = (checkdata.SelectRow.DataSource as DataRow)["RId"].ToString();

            admin_checkCarFrm checkCarFrm = new admin_checkCarFrm();
            checkCarFrm.id = id;
            checkCarFrm.ShowDialog();
        }
    }
}
